home *** CD-ROM | disk | FTP | other *** search
- { sgHooks.i }
-
- {$I "Include:Exec/Types.i"}
-
- Type
- StringExtend = Record
- { display specifications }
- Font : TextFontPtr; { must be an open Font (not TextAttr) }
- Pens : Array[0..1] of Byte; { color of text/backgroun }
- ActivePens : Array[0..1] of Byte; { colors when gadget is active }
-
- { edit specifications }
- InitialModes : Integer; { initial mode flags, below }
- EditHook : HookPtr; { IF non-NULL, must supply WorkBuffer }
- WorkBuffer : String; { must be as large as StringInfo.Buffer}
-
- Reserved : Array[0..3] of Integer; { set to 0 }
- END;
- StringExtendPtr = ^StringExtend;
-
- SGWork = Record
- { set up when gadget is first activated }
- Gad : GadgetPtr; { the contestant itself } { Gadget in C-Includes }
- StrInfo : StringInfoPtr; { easy access to sinfo } { StrInfo in C-Includes }
- WorkBuffer : String; { intuition's planned result }
- PrevBuffer : String; { what was there before }
- Modes : Integer; { current mode }
-
- { modified for each input event }
- IEvent : InputEventPtr; { actual event: do not change }
- Code : Short; { character code, IF one byte }
- BufferPos : Short; { cursor position }
- NumChars : Short;
- Actions : Integer; { what Intuition will do }
- LongInt : Integer; { temp storage for longint }
-
- GInfo : GadgetInfoPtr; { see cghooks.h } { GadgetInfo in C-Includes }
- EditOp : Short; { from constants below }
- END;
- SGWorkPtr = ^SGWork;
-
- { SGWork.EditOp -
- * These values indicate what basic type of operation the global
- * editing hook has performed on the string before your gadget's custom
- * editing hook gets called. You do not have to be concerned with the
- * value your custom hook leaves in the EditOp field, only if you
- * write a global editing hook.
- *
- * For most of these general edit operations, you'll want to compare
- * the BufferPos and NumChars of the StringInfo (before global editing)
- * and SGWork (after global editing).
- }
-
- CONST
- EO_NOOP = ($0001);
- { did nothing }
- EO_DELBACKWARD= ($0002);
- { deleted some chars (maybe 0). }
- EO_DELFORWARD = ($0003);
- { deleted some characters under and in front of the cursor }
- EO_MOVECURSOR = ($0004);
- { moved the cursor }
- EO_ENTER = ($0005);
- { "enter" or "return" key, terminate }
- EO_RESET = ($0006);
- { current Intuition-style undo }
- EO_REPLACECHAR= ($0007);
- { replaced one character and (maybe) advanced cursor }
- EO_INSERTCHAR = ($0008);
- { inserted one char into string or added one at end }
- EO_BADFORMAT = ($0009);
- { didn't like the text data, e.g., Bad LONGINT }
- EO_BIGCHANGE = ($000A); { unused by Intuition }
- { complete or major change to the text, e.g. new string }
- EO_UNDO = ($000B); { unused by Intuition }
- { some other style of undo }
- EO_CLEAR = ($000C);
- { clear the string }
- EO_SPECIAL = ($000D); { unused by Intuition }
- { some operation that doesn't fit into the categories here }
-
-
- { Mode Flags definitions (ONLY first group allowed as InitialModes) }
- SGM_REPLACE = (1); { replace mode }
- { please initialize StringInfo with in-range value of BufferPos
- * if you are using SGM_REPLACE mode.
- }
-
- SGM_FIXEDFIELD = (2); { fixed length buffer }
- { always set SGM_REPLACE, too }
- SGM_NOFILTER = (4); { don't filter control chars }
-
- { SGM_EXITHELP is new for V37, and ignored by V36: }
- SGM_EXITHELP = (128); { exit with code = $5F IF HELP hit }
-
-
- { These Mode Flags are for internal use only }
- SGM_NOCHANGE = (8); { no edit changes yet }
- SGM_NOWORKB = (16); { Buffer == PrevBuffer }
- SGM_CONTROL = (32); { control char escape mode }
- SGM_LONGINT = (64); { an intuition longint gadget }
-
- { String Gadget Action Flags (put in SGWork.Actions by EditHook) }
- SGA_USE = ($1); { use contents of SGWork }
- SGA_END = ($2); { terminate gadget, code in Code field }
- SGA_BEEP = ($4); { flash the screen for the user }
- SGA_REUSE = ($8); { reuse input event }
- SGA_REDISPLAY = ($10); { gadget visuals changed }
-
- { New for V37: }
- SGA_NEXTACTIVE = ($20); { Make next possible gadget active. }
- SGA_PREVACTIVE = ($40); { Make previous possible gadget active.}
-
- { function id for only existing custom string gadget edit hook }
-
- SGH_KEY = (1); { process editing keystroke }
- SGH_CLICK = (2); { process mouse click cursor position }
-
- { Here's a brief summary of how the custom string gadget edit hook works:
- * You provide a hook in StringInfo.Extension.EditHook.
- * The hook is called in the standard way with the 'object'
- * a pointer to SGWork, and the 'message' a pointer to a command
- * block, starting either with (longword) SGH_KEY, SGH_CLICK,
- * or something new.
- *
- * You return 0 if you don't understand the command (SGH_KEY is
- * required and assumed). Return non-zero if you implement the
- * command.
- *
- * SGH_KEY:
- * There are no parameters following the command longword.
- *
- * Intuition will put its idea of proper values in the SGWork
- * before calling you, and if you leave SGA_USE set in the
- * SGWork.Actions field, Intuition will use the values
- * found in SGWork fields WorkBuffer, NumChars, BufferPos,
- * and LongInt, copying the WorkBuffer back to the StringInfo
- * Buffer.
- *
- * NOTE WELL: You may NOT change other SGWork fields.
- *
- * If you clear SGA_USE, the string gadget will be unchanged.
- *
- * If you set SGA_END, Intuition will terminate the activation
- * of the string gadget. If you also set SGA_REUSE, Intuition
- * will reuse the input event after it deactivates your gadget.
- *
- * In this case, Intuition will put the value found in SGWork.Code
- * into the IntuiMessage.Code field of the IDCMP_GADGETUP message it
- * sends to the application.
- *
- * If you set SGA_BEEP, Intuition will call DisplayBeep(); use
- * this if the user has typed in error, or buffer is full.
- *
- * Set SGA_REDISPLAY if the changes to the gadget warrant a
- * gadget redisplay. Note: cursor movement requires a redisplay.
- *
- * Starting in V37, you may set SGA_PREVACTIVE or SGA_NEXTACTIVE
- * when you set SGA_END. This tells Intuition that you want
- * the next or previous gadget with GFLG_TABCYCLE to be activated.
- *
- * SGH_CLICK:
- * This hook command is called when Intuition wants to position
- * the cursor in response to a mouse click in the string gadget.
- *
- * Again, here are no parameters following the command longword.
- *
- * This time, Intuition has already calculated the mouse position
- * character cell and put it in SGWork.BufferPos. The previous
- * BufferPos value remains in the SGWork.StringInfo.BufferPos.
- *
- * Intuition will again use the SGWork fields listed above for
- * SGH_KEY. One restriction is that you are NOT allowed to set
- * SGA_END or SGA_REUSE for this command. Intuition will not
- * stand for a gadget which goes inactive when you click in it.
- *
- * You should always leave the SGA_REDISPLAY flag set, since Intuition
- * uses this processing when activating a string gadget.
- }
-
-
-